package com.qf.product.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.qf.product.entity.Product;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 * 产品表 Mapper 接口
 * </p>
 *
 * @author 
 * @since 2023-10-26
 */
@Mapper
public interface ProductMapper extends BaseMapper<Product> {
    @Select("SELECT\n" +
            "\tqf_product.tenant_id, \n" +
            "\tqf_product.`name`, \n" +
            "\tqf_product.product_key, \n" +
            "\tqf_product.username, \n" +
            "\tqf_product.`password`, \n" +
            "\tqf_product.create_time\n" +
            "FROM\n" +
            "\tqf_product\n" +
            "\tINNER JOIN\n" +
            "\tqf_tenant\n" +
            "\tON \n" +
            "\t\tqf_product.tenant_id = qf_tenant.id\n" +
            "WHERE\n" +
            "\tqf_product.id = #{id}")
    public List<Product> findByProductId(Long productId);

    Product findOneByDeviceId(@Param("id") Long id);
}
